﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;

namespace Platformer
{
    class Sword
    {
        Vector2 anchor;
        Vector2 pos;
        Texture2D sprite;
        bool isSwinging;
        float rad;
        public Rectangle bounding;
        bool isRight;
        Level l;

        public Sword(Vector2 pos, Level l)
        {
            sprite = l.Content.Load<Texture2D>("Sprites\\Sword");
            rad = 0;
            anchor = new Vector2(0, sprite.Height / 2);
            this.l = l;
        }

        public void Update()
        {
            if (l.Player.FacingLeft)
            {
                isRight = false;
            }
            else
            {
                isRight = true;
            }
            this.pos = l.Player.Position;
            this.pos.Y -= l.Player.BoundingRectangle.Height / 2 +10;
        }


        public void Draw(SpriteBatch batch)
        {
            new Vector2(sprite.Width / 2, sprite.Height / 2);
            if (isRight)
            {
                batch.Draw(sprite, pos, null, Color.White, 0.0f, anchor, 0.5f, SpriteEffects.None, 1.0f);
            }
            else
            {
                batch.Draw(sprite, pos, null, Color.White, (float)Math.PI, anchor, 0.5f, SpriteEffects.None, 1.0f);
            }
        }
    }
}
